home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-17 | 1.3 KB | 57 lines | [TEXT/CWIE] |
- // ApplicationWaker.h
-
- #ifndef ApplicationWaker_h
- #define ApplicationWaker_h
-
- #ifndef A5_h
- #include "A5.h"
- #endif
- #ifndef __TIMER__
- #include <Timer.h>
- #endif
- #ifndef __PROCESSES__
- #include <Processes.h>
- #endif
-
- /*
- This class is a way out of a timing problem: When an interrupt task
- wants a rendezvous with the application, it has to make sure the
- application wakes up. But WakeUpProcess alone won't do the job;
- the application might be on its way to bed, but not asleep enough for
- WakeUpProcess to do anything. The solution is to keep calling
- WakeUpProcess until the application wakes up.
- */
-
- class ApplicationWaker
- {
- private:
- ProcessSerialNumber process;
- volatile bool awake;
- volatile bool ringing;
- volatile bool canSleep;
- TMTask timeTask;
- A5 a5;
-
- static pascal void RingAlarmGlue();
- static pascal void RingAlarm( ApplicationWaker * );
-
- ApplicationWaker();
-
- public:
- // Make sure the first call, which initializes the object,
- // is from application time.
- static ApplicationWaker& The();
-
- // Call this from interrupt time to wake the application.
- void StartAlarm();
-
- // Call this from application time when the application wakes up.
- void StopAlarm();
-
- // Call this before going to sleep. If it returns false, use a sleep
- // time of zero.
- bool CanSleep();
- };
-
- #endif
-